package com.daily.DailyStudy.kafka.provider;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

@Component
public class ProductTest {

    @Autowired
    private KafkaTemplate kafkaTemplate;

    public void send (String name){
        JSONObject json = new JSONObject();
        json.put("name",name);
        json.put("age",26);
        System.out.println("生产者数据："+json.toJSONString());
        kafkaTemplate.send("user_test",json.toJSONString());
    }


}
